/**
 *
 */
package org.whuims.pois.dao;

import org.whuims.pois.action.result.ClusterVo;
import org.whuims.pois.hibernate.BaseDao;
import org.whuims.pois.model.Cluster;

import java.util.List;

/**
 * @author herochen
 * @date 2010-4-17 @time 下午08:49:39
 */
public class ClusterDao {
    BaseDao baseDao = new BaseDao();

    /**
     * 读取聚类结果
     *
     * @param topicId                      主题ID
     * @param type：类型，today,week,yesterday
     */
    public List<ClusterVo> getClusterList(long topicId, String type) {
        List<ClusterVo> list = baseDao.findByParamsArr(
                "select new org.whuims.pois.action.result.ClusterVo(c.id,c.recordid , d.titlecontent , d.titlelink , d.abstext , c.count, c.value , c.crawltime, c.type,c.category) " +
                        "from Cluster c,DataC d where c.recordid=d.id and c.topicId=? and c.type=?", topicId, type
        );
        return list;
    }
    public Object get(long id){return baseDao.getByPk(Cluster.class, id);}

    public List<ClusterVo> getYesterdayList(long topicId) {
        return getClusterList(topicId, "yesterday");
    }

    public List<ClusterVo> getTodayList(long topicId) {
        return getClusterList(topicId, "today");
    }

    public List<ClusterVo> getWeekList(long topicId) {
        return getClusterList(topicId, "week");
    }
}
